package link;

public class cycleLink {
    public Boolean hasCycle(ListNode head){
        ListNode slow = head;
        ListNode fast= head.next;
        while(slow!=fast){
            if (slow==null || fast.next==null){
                return false;
            }
            slow=slow.next;
            fast=fast.next.next;
        }
        return true;

    }
}
